package nio.buffter;

import java.nio.IntBuffer;
//读写
public class buffterTest1 {
    public static void main(String[] args) {
        //大小为5 类型为int的buffer
        IntBuffer allocate = IntBuffer.allocate(5);
        //存放
        for (int i = 0;i < allocate.capacity(); i++){
            allocate.put(i * 2);
            System.out.println("posion"+allocate.position());
        }
        //取
        allocate.flip();//读写切换
        while (allocate.hasRemaining()){
            System.out.println("data"+allocate.get()+" posion"+allocate.position());
        }
    }
}
